﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace pGrid
{
  public partial class RemoveStations : Window
  {
    private int m_selected_station_num;
    private int m_bought_num;

    public RemoveStations()
    {
      InitializeComponent();
    }
    public void SetStations(Player cur_player)
    {
      if (cur_player.BuyFourthStation)
      {
        AddColumns();
        SetThreeStations(cur_player);
        SetFourthStation(cur_player);
      }
      else
      {
        SetThreeStations(cur_player);
      }
    }
    public void AddColumns()
    {
      ColumnDefinition col4 = new ColumnDefinition();
      col4.Width = grid1.ColumnDefinitions.ElementAt(1).Width;
      ColumnDefinition col5 = new ColumnDefinition();
      col5.Width = grid1.ColumnDefinitions.ElementAt(0).Width;
      this.grid1.ColumnDefinitions.Add(col4);
      this.grid1.ColumnDefinitions.Add(col5);
    }
    public void SetFourthStation(Player cur_player)
    {
      Image st4 = new Image();
      Grid.SetColumn(st4, 7);
      Grid.SetRow(st4, 3);
      st4.MouseDown += new System.Windows.Input.MouseButtonEventHandler(st4_MouseDown);
      st4.Source = cur_player.Station4.Pic;
      grid1.Children.Add(st4);
    }
    public void SetThreeStations(Player cur_player)
    {
      Image st1 = new Image();
      Image st2 = new Image();
      Image st3 = new Image();

      Grid.SetColumn(st1, 1);
      Grid.SetRow(st1, 3);
      Grid.SetColumn(st2, 3);
      Grid.SetRow(st2, 3);
      Grid.SetColumn(st3, 5);
      Grid.SetRow(st3, 3);

      st1.MouseDown += new System.Windows.Input.MouseButtonEventHandler(st1_MouseDown);
      st2.MouseDown += new System.Windows.Input.MouseButtonEventHandler(st2_MouseDown);
      st3.MouseDown += new System.Windows.Input.MouseButtonEventHandler(st3_MouseDown);

      st1.Source = cur_player.Station1.Pic;
      st2.Source = cur_player.Station2.Pic;
      st3.Source = cur_player.Station3.Pic;

      grid1.Children.Add(st1);
      grid1.Children.Add(st2);
      grid1.Children.Add(st3);



    }
    public int SelectedNum
    {
      get
      {
        return m_selected_station_num;
      }
    }
    public int BoughtNum
    {
      get
      {
        return m_bought_num;
      }
      set
      {
        m_bought_num = value;
      }
    }

    private void st1_MouseDown(object sender, MouseButtonEventArgs e)
    {
      m_selected_station_num = 1;
      this.Close();
    }

    private void st2_MouseDown(object sender, MouseButtonEventArgs e)
    {
      m_selected_station_num = 2;
      this.Close();
    }

    private void st3_MouseDown(object sender, MouseButtonEventArgs e)
    {
      m_selected_station_num = 3;
      this.Close();
    }

    private void st4_MouseDown(object sender, MouseButtonEventArgs e)
    {
      m_selected_station_num = 4;
      this.Close();
    }
  }
}
